#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pii pair<long long,long long>
#define pb push_back
#define mp make_pair
const int mod=998244353;
int fpow(int x,int b)
{
    if(!b) return 1;
    if(!x) return 0;
    int res=1;
    while(b)
    {
        if(b&1) res=1LL*res*x%mod;
        b>>=1;
        x=1LL*x*x%mod;
    }
    return res;
}
int facs,n=1,A,B;
int calc(int d)
{
    int cnt=__gcd(n,d),len=n/cnt;
    int es=cnt*(cnt-1)/2*len;
    es+=(len/2)*cnt;
    return fpow(A,cnt)*fpow(B,es)%mod;
}
int calc2(int c1,int c2)
{
    int es=c2+c2*(c2-1);
    if(c1==1) es+=c2;
    else if(c1==2) es+=1+2*c2;
    return fpow(A,c1+c2)*fpow(B,es)%mod;
}
void solve()
{
    cin>>facs;
    for(int i=1;i<=facs;i++)
    {
        int x;
        cin>>x;
        n*=x;
    }
    cin>>A>>B;
    int ans=0;
    A%=mod,B%=mod;
    for(int d=0;d<n;d++) ans=(ans+calc(d))%mod;
    if(n%2==0) ans=(ans+n/2*calc2(0,n/2)+n/2*calc2(2,n/2-1))%mod;//,assert(calc2(0,n/2)==calc(n/2));
    else ans=(ans+n*calc2(1,n/2))%mod;
    cout<<ans*fpow(n+n,mod-2)%mod<<"\n";
}
signed main()
{
    freopen("clown.in","r",stdin);
    freopen("clown.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int _=1;
    // cin>>_;
    while(_--) solve();
    return 0;
}

/*
g++ -o clown clown.cpp -O2 -std=c++14 -Wall -Wextra -Wconversion -Wshadow

g++ -o clown clown.cpp -O2 -std=c++14 -Wall -Wextra -Wconversion -Wshadow -fsanitize=undefined -fsanitize=address -D_GLIBCXX_DEBUG -g 
*/